package com.ruoyi.wzy.test.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.wzy.test.domain.WzyTest;
import com.ruoyi.wzy.test.service.IWzyTestService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 王贞营测试Controller
 * 
 * @author wzy
 * @date 2020-04-28
 */
@Controller
@RequestMapping("/test/test")
public class WzyTestController extends BaseController
{
    private String prefix = "test/test";

    @Autowired
    private IWzyTestService wzyTestService;

    @RequiresPermissions("test:test:view")
    @GetMapping()
    public String test()
    {
        return prefix + "/test";
    }

        /**
     * 查询王贞营测试列表
     */
    @RequiresPermissions("test:test:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(WzyTest wzyTest)
    {
        startPage();
        List<WzyTest> list = wzyTestService.selectWzyTestList(wzyTest);
        return getDataTable(list);
    }
    
    /**
     * 导出王贞营测试列表
     */
    @RequiresPermissions("test:test:export")
    @Log(title = "王贞营测试", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(WzyTest wzyTest)
    {
        List<WzyTest> list = wzyTestService.selectWzyTestList(wzyTest);
        ExcelUtil<WzyTest> util = new ExcelUtil<WzyTest>(WzyTest.class);
        return util.exportExcel(list, "test");
    }

    /**
     * 新增王贞营测试
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存王贞营测试
     */
    @RequiresPermissions("test:test:add")
    @Log(title = "王贞营测试", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(WzyTest wzyTest)
    {
        return toAjax(wzyTestService.insertWzyTest(wzyTest));
    }

    /**
     * 修改王贞营测试
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        WzyTest wzyTest = wzyTestService.selectWzyTestById(id);
        mmap.put("wzyTest", wzyTest);
        return prefix + "/edit";
    }

    /**
     * 修改保存王贞营测试
     */
    @RequiresPermissions("test:test:edit")
    @Log(title = "王贞营测试", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(WzyTest wzyTest)
    {
        return toAjax(wzyTestService.updateWzyTest(wzyTest));
    }

    /**
     * 删除王贞营测试
     */
    @RequiresPermissions("test:test:remove")
    @Log(title = "王贞营测试", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(wzyTestService.deleteWzyTestByIds(ids));
    }
}
